//
//  ViewController2.m
//  Appsetting
//
//  Created by student on 16/3/16.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController2.h"

@interface ViewController2 ()
@property (weak, nonatomic) IBOutlet UISwitch *uiswitch;
@property (weak, nonatomic) IBOutlet UISlider *speedsilder;

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self updateInfo];
    

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateInfo) name:UIApplicationWillEnterForegroundNotification object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)back:(id)sender
{
    [self dismissViewControllerAnimated:YES completion:nil];
}
- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)updateInfo
{
    NSUserDefaults *d = [NSUserDefaults standardUserDefaults];
    
    self.uiswitch.on = [d boolForKey:@"wrap"];
    self.speedsilder.value = [d floatForKey:@"wrapSpeed"];
}
- (IBAction)open:(UISwitch *)sender
{
    NSUserDefaults *d = [NSUserDefaults standardUserDefaults];
    [d setBool:sender.on forKey:@"wrap"];
    
    [d synchronize];

}
- (IBAction)change:(UISlider *)sender
{
    NSUserDefaults *d = [NSUserDefaults standardUserDefaults];
    [d setFloat:sender.value forKey:@"wrapSpeed"];
    
    [d synchronize];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
